package cn.softwin.dao.impl;


import cn.softwin.dao.VisitTimeDao;
import cn.softwin.pojo.SaleVisit;
import cn.softwin.utils.JDBCpoolUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class VisitTimeDaoImpl implements VisitTimeDao {
    // 操作数据库的dao
    private Connection con = null;
    private PreparedStatement pstat = null;


    public boolean addVisitTime(SaleVisit visitTime) {


        try {
            con = JDBCpoolUtils.getConnection();
            String sql = "insert into sale_visit (visit_cust_id,visit_user_id,visit_time,visit_interviewee,visit_addr,visit_detail,visit_nexttime) values(?,?,?,?,?,?,?)";
            pstat = con.prepareStatement(sql);
            pstat.setString(1, visitTime.getVisitCustId());
            pstat.setString(2, visitTime.getVisitUserId());
            pstat.setString(3, visitTime.getVisitTime());
            pstat.setString(4, visitTime.getVisitInterviewee());
            pstat.setString(5, visitTime.getVisitAddr());
            pstat.setString(6, visitTime.getVisitDetail());
            pstat.setString(7, visitTime.getVisitNextTime());
            int count = pstat.executeUpdate();
            if (count>0) {
                return true;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            JDBCpoolUtils.close(pstat, con);
        }
        return false;
    }
}
